package com.yaoli.niuke;

import java.util.Scanner;

/**
 * Created by will on 2017/6/1.
 */
public class _023_Test {
    public static void main(String args[]){
//        Scanner input = new Scanner(System.in);
//        int a = input.nextInt();
//        int set [] = new int[a];
//        for(int i = 0 ;i < a; i++){
//            set[i] = input.nextInt();
//        }
        int set [] = {1,2 ,3 ,2 ,2 ,1};

        int count = 0;
        for(int i = 0 ; i < set.length;){
            boolean zeng = zeng(set,i);
            if(zeng == true){
                i = zengT(set,i);
            }else{
                i = jianT(set,i);
            }
            count++;
        }

        System.out.println(count);
    }

    public static int zengT(int set[],int j){
        int i = j;
        for(; i < set.length -1; i++){
            if(set[i] <= set[i+1]){
                continue;
            }else{
                return i + 1;
            }
        }

        return i + 1;
    }

    public static int jianT(int set[] ,int j){
        int i = j;
        for(; i < set.length - 1 ; i ++){
            if(set[i] >= set[i + 1]){
                continue;
            }else{
                return i+1;
            }
        }

        return i + 1;
    }

    public static boolean zeng(int set[] ,int i){
        for(int j = i + 1 ; j < set.length ; j++){
            if(set[i] == set[j]){
                continue;
            }
            if(set[i] < set[j]){
                return true;
            }

            if(set[i] > set[j]){
                return false;
            }
        }

        return true;
    }
}
